export const QUESTIONS = [
  {
    id: 'q1',
    level: 'easy',
    category: 'javascript',
    title: 'JavaScript 基础：数组长度',
    content: '问：`[1,2,3].length` 的值是多少？',
    choices: [
      { key: 'A', text: '2' },
      { key: 'B', text: '3' },
      { key: 'C', text: '4' },
    ],
    answers: ['B', '3'],
    explanation: '数组包含 3 个元素，length 返回元素个数。',
    points: 10,
  },
  {
    id: 'q2',
    level: 'easy',
    category: 'typescript',
    title: 'TypeScript：类型断言关键字',
    content: '问：TypeScript 中进行类型断言可使用哪个关键字？',
    choices: [
      { key: 'A', text: 'as' },
      { key: 'B', text: 'is' },
      { key: 'C', text: 'typeof' },
    ],
    answers: ['A', 'as'],
    explanation: '类型断言使用 `as` 语法。',
    points: 10,
  },
  {
    id: 'q3',
    level: 'easy',
    category: 'http',
    title: 'HTTP：常见成功状态码',
    content: '问：表示成功的最常见 HTTP 状态码是？',
    choices: [
      { key: 'A', text: '200' },
      { key: 'B', text: '404' },
      { key: 'C', text: '500' },
    ],
    answers: ['A', '200'],
    explanation: '200 OK 表示请求成功。',
    points: 10,
  },
  {
    id: 'q4',
    level: 'medium',
    category: 'vue',
    title: 'Vue 3：计算属性',
    content: '问：Vue 3 中创建计算属性应使用哪个 API？',
    choices: [
      { key: 'A', text: 'ref' },
      { key: 'B', text: 'reactive' },
      { key: 'C', text: 'computed' },
    ],
    answers: ['C', 'computed'],
    explanation: '使用 `computed` 定义计算属性。',
    points: 20,
  },
  {
    id: 'q5',
    level: 'medium',
    category: 'git',
    title: 'Git：创建新分支命令',
    content: '问：创建并切换到新分支的命令是？',
    choices: [
      { key: 'A', text: 'git branch new && git checkout new' },
      { key: 'B', text: 'git checkout -b new' },
      { key: 'C', text: 'git switch new --create' },
    ],
    answers: ['B', 'git checkout -b new'],
    explanation: '常用 `git checkout -b <branch>`，或 `git switch -c <branch>`。',
    points: 20,
  },
  {
    id: 'q6',
    level: 'medium',
    category: 'css',
    title: 'CSS：Flex 布局主轴对齐',
    content: '问：在 Flex 布局中控制主轴对齐的属性是？',
    choices: [
      { key: 'A', text: 'align-items' },
      { key: 'B', text: 'justify-content' },
      { key: 'C', text: 'place-items' },
    ],
    answers: ['B', 'justify-content'],
    explanation: '主轴使用 `justify-content`，交叉轴使用 `align-items`。',
    points: 20,
  },
  {
    id: 'q7',
    level: 'medium',
    category: 'performance',
    title: '性能：节流与防抖',
    content: '问：防抖（debounce）与节流（throttle）哪个确保间隔内最多执行一次？',
    choices: [
      { key: 'A', text: '防抖 debounce' },
      { key: 'B', text: '节流 throttle' },
    ],
    answers: ['B', 'throttle', '节流'],
    explanation: '节流保证固定间隔最多执行一次；防抖是延迟直到空闲。',
    points: 20,
  },
  {
    id: 'q8',
    level: 'hard',
    category: 'algorithm',
    title: '算法：二分查找时间复杂度',
    content: '问：有序数组的二分查找时间复杂度是？',
    choices: [
      { key: 'A', text: 'O(n)' },
      { key: 'B', text: 'O(log n)' },
      { key: 'C', text: 'O(1)' },
    ],
    answers: ['B', 'O(log n)', 'logn'],
    explanation: '每次折半，复杂度为 O(log n)。',
    points: 30,
  },
  {
    id: 'q9',
    level: 'hard',
    category: 'http',
    title: 'HTTP/缓存：ETag 用途',
    content: '问：ETag 主要用于哪类缓存校验？',
    choices: [
      { key: 'A', text: '强缓存' },
      { key: 'B', text: '协商缓存' },
    ],
    answers: ['B', '协商缓存'],
    explanation: 'ETag/If-None-Match 用于协商缓存对比。',
    points: 30,
  },
  {
    id: 'q10',
    level: 'hard',
    category: 'security',
    title: '安全：CSRF 防护常用手段',
    content: '问：后端防止 CSRF 的常见做法是？',
    choices: [
      { key: 'A', text: '使用验证码' },
      { key: 'B', text: '使用 CSRF Token 并校验' },
      { key: 'C', text: '开启 CORS' },
    ],
    answers: ['B', 'csrf token'],
    explanation: '校验 CSRF Token；同时注意 SameSite Cookie 等。',
    points: 30,
  },
  {
    id: 'q11',
    level: 'easy',
    category: 'node',
    title: 'Node.js：包管理器',
    content: '问：常见包管理器不包括哪一个？',
    choices: [
      { key: 'A', text: 'npm' },
      { key: 'B', text: 'pnpm' },
      { key: 'C', text: 'pip' },
    ],
    answers: ['C', 'pip'],
    explanation: 'pip 是 Python 的包管理器。',
    points: 10,
  },
  {
    id: 'q12',
    level: 'medium',
    category: 'typescript',
    title: 'TypeScript：联合类型',
    content: '问：`type A = string | number` 属于哪类类型？',
    choices: [
      { key: 'A', text: '交叉类型' },
      { key: 'B', text: '联合类型' },
      { key: 'C', text: '泛型' },
    ],
    answers: ['B', '联合类型'],
    explanation: '使用 `|` 定义联合类型。',
    points: 20,
  },
  {
    id: 'q13',
    level: 'medium',
    category: 'browser',
    title: '浏览器：事件捕获与冒泡顺序',
    content: '问：默认情况下事件先发生捕获还是冒泡？',
    choices: [
      { key: 'A', text: '先捕获后冒泡' },
      { key: 'B', text: '先冒泡后捕获' },
    ],
    answers: ['A', '先捕获后冒泡', 'capture'],
    explanation: '事件流为捕获 → 目标 → 冒泡。',
    points: 20,
  },
  {
    id: 'q14',
    level: 'hard',
    category: 'database',
    title: '数据库：索引类型',
    content: '问：B+ 树索引的特点之一是？',
    choices: [
      { key: 'A', text: '叶子节点存储数据并有顺序链表' },
      { key: 'B', text: '所有节点都存数据' },
      { key: 'C', text: '不适合范围查询' },
    ],
    answers: ['A'],
    explanation: 'B+ 树叶子节点形成有序链表，适合范围查询。',
    points: 30,
  },
  {
    id: 'q15',
    level: 'easy',
    category: 'html',
    title: 'HTML：语义化标签',
    content: '问：表示导航的语义化标签是？',
    choices: [
      { key: 'A', text: '<section>' },
      { key: 'B', text: '<nav>' },
      { key: 'C', text: '<aside>' },
    ],
    answers: ['B', '<nav>', 'nav'],
    explanation: '使用 `<nav>` 表示导航区域。',
    points: 10,
  },
  {
    id: 'q16',
    level: 'medium',
    category: 'security',
    title: '安全：XSS 防护',
    content: '问：防止 XSS 的常见方式是？',
    choices: [
      { key: 'A', text: '输出编码/转义' },
      { key: 'B', text: '只使用 GET 请求' },
      { key: 'C', text: '禁用 Cookie' },
    ],
    answers: ['A', '转义', 'escape', '输出编码'],
    explanation: '对输出进行编码/转义，配合 CSP 等策略。',
    points: 20,
  },
  {
    id: 'q17',
    level: 'hard',
    category: 'network',
    title: '网络：TCP 三次握手目的',
    content: '问：TCP 三次握手主要用于？',
    choices: [
      { key: 'A', text: '确认双方收发能力' },
      { key: 'B', text: '加密数据' },
      { key: 'C', text: '减少延迟' },
    ],
    answers: ['A', '确认收发能力'],
    explanation: '用于同步序列号并确认双方的收发能力。',
    points: 30,
  },
  {
    id: 'q18',
    level: 'medium',
    category: 'vue',
    title: 'Vue 3：组合式 API 引入',
    content: '问：组合式 API 需要从哪个包引入？',
    choices: [
      { key: 'A', text: 'vue' },
      { key: 'B', text: 'vue-router' },
      { key: 'C', text: 'pinia' },
    ],
    answers: ['A', 'vue'],
    explanation: '如 `import { ref, computed } from "vue"`。',
    points: 20,
  },
];

export const QUESTION_CATEGORIES = [
  'javascript',
  'typescript',
  'vue',
  'http',
  'security',
  'css',
  'performance',
  'algorithm',
  'node',
  'browser',
  'database',
  'html',
  'network',
];